
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>修改密码</title>
<style type="text/css">
body,html {
	min-height: 500px;
	background-color: darkcyan;
}

#box {
	width: 100%;
	padding-bottom: 20px;
	box-shadow: 0px 0px 5px #fff;
	margin: 0 auto;
	margin-top: 20px;
	background: #fff;
	text-align:center
}

#box #title {
	text-indent: 15px;
	height: 40px;
	line-height: 40px;
	width: 100%;
	background: #D8D8D8;
}

#box #inputForm {
	margin-top: 20px;
}
body{
background-color: darkcyan;
}
</style>
<%@include file="/common/head.jsp" %>
<script type="text/javascript" src="${ctxStatic}/CryptoJS/components/core-min.js" charset="utf-8" ></script>
<script type="text/javascript" src="${ctxStatic}/CryptoJS/rollups/sha256.js" charset="utf-8" ></script>
<script type="text/javascript">
        $(document).ready(function() {
            $("#oldPdcode").focus();
            $("#inputForm").validate({
                rules: {
                    newPdcode:{
                        loginPdcode:true,
                    }
                },
                messages: {
                    confirmNewPdcode: {equalTo: "输入与上面相同的密码"},
                    oldPdcode:{
                        remote:"原始密码错误"
                    },
                    newPdcode:{
                        remote:"不能和原始密码一样"
                    }
                },
                submitHandler: function(form){
                    loading("修改密码中...");
                    var username=$('#username').val();
                    var oldPdcode=$('#oldPdcode').val(); 
                    var newPdcode=$('#newPdcode').val(); 
                    oldPdcode= CryptoJS.SHA256(oldPdcode+"{"+username+"}");
                    newPdcode= CryptoJS.SHA256(newPdcode+"{"+username+"}");
                    $('#oldPdcode').val(oldPdcode);
                    $('#newPdcode').val(newPdcode);
                    $('#confirmNewPdcode').val(newPdcode);
                    form.submit();
                },
                errorContainer: "#messageBox",
                errorPlacement: function(error, element) {
                    $("#messageBox").text("输入有误，请先更正。");
                    if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
                        error.appendTo(element.parent().parent());
                    } else {
                        error.insertAfter(element);
                    }
                }
            });
            //隐藏返回首页和退出登录
            $('#out').attr("style","display:none");
            $('#logout').attr("style","display:none");
        });
    </script>
</head>
<body>
<div id="box">
    <div id="title">
     <span style="font-size:16px; color: red;">友情提示：</span>
     <span style="font-size: 14px">请定期修改您的密码，以确保账户安全性</span>
    </div>
    <c:if test="${msg != ''}">
    	<div><label>错误提示:</label><span style="color:red">${msg}</span></div>
    </c:if>
    <form id="inputForm" action="${ctx}/user/firstChangepw.do" 
        method="post" class="form-horizontal">
        <div style="width:50%;margin:auto">
        <input type="hidden" name="id" value="${id}">
         <tags:message content="${msg}"/>
        <div class="control-group">
            <label class=" control-label">旧密码<font style="color:red">*</font>:</label>
            <div class="controls">
                <input id="oldPdcode" name="oldPdcode" type="password" value="" class="required"/>
            </div>
        </div>
        <div class="control-group">
            <label class=" control-label">新密码<font style="color:red">*</font>:</label>
            <div class="controls">
                <input id="newPdcode" name="newPdcode" type="password" value=""  class="required"/>
                <br/>
                <br/>
                <span>(密码必须包含大写字母、小写字母、数字,长度在8~12位之间)</span>
            </div>
        </div>
        <div class="control-group">
            <label class=" control-label">确认新密码<font style="color:red">*</font>:</label>
            <div class="controls">
                <input id="confirmNewPdcode" name="confirmNewPdcode" type="password" value="" class="required" equalTo="#newPdcode"/>
            </div>
        </div>
        <div >
        <input type="hidden" id="username" name="username" value="${user.username}">
                <input id="btnSubmit" class="btn bprimary" type="submit" value="保 存"/>
        </div>
        </div>
    </form>
</div>
</body>
